/*******************************************************
> Copyright (C) 2024 ==IOT== All rights reserved.
> File Name: date_time.cpp
> Author: IOT
> Website:www.slq.org
> Created Time: 2024年10月25日 星期五 14时33分12秒
***************************************************/

#include <iostream>
#include <string>
using namespace std;
typedef unsigned char u8;

class Time {
    u8 hour;
    u8 min;
    u8 sec;
    public:
        Time(u8 h, u8 m, u8 s) : hour(h), min(m), sec(s)
        {

        }
        string toString()
        {
			return to_string(hour) + ":" + to_string(min) + ":" + to_string(sec);
			//return string(nullptr);
        }
};
class Date {
    u8 day;
    u8 mon;
    int year;
    public:
        Date(int y, u8 m, u8 d) : year(y), mon(m), day(d)
        {

        }
        string toString()
        {
			return to_string(year) + "-" + to_string(mon) + "-" + to_string(day);
			//return string(nullptr);
        }
		int getYear()
		{
			return year;
		}
};

class DateTime : public Time, public Date {
    public: 
        DateTime(int year, u8 mon, u8 day, u8 hour, u8 min, u8 sec) : Date(year,mon,day), Time(hour, min, sec)
        {
            
        }
        string toString()
        {
			//cout << year << endl;
			//return string(nullptr);
			return Date::toString() + " " + Time::toString(); // 继承到同名函数或变量时用基类域作用运算符区分
        }
};

int main(int argc,const char* argv[])
{
	DateTime dt(2024, 10, 25, 14, 35, 12);
	cout << sizeof(dt) << endl;
	
	//unsigned i;
	//cout << sizeof(i) << endl;
	cout << dt.toString() << endl;
    return 0;
}
